import { Component } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {isLineBreak} from "codelyzer/angular/sourceMappingVisitor";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  sg:string;
  tz:string;
  result:number;
  suggest:string;
  imgurl:string;
  suggestvalue:string;
  constructor(private http:HttpClient) {

  }
  getBmiValue(){
console.log("身高是"+this.sg+"体重是"+this.tz);
let parm={

  "sg":this.sg,
  "tz":this.tz
}
let url="http://localhost:8080/bmivalue";
this.http.post(url,parm).toPromise()
  .then((data:any)=>
  {
    console.dir(data);
    this.result=data.result;
    this.suggest=data.suggest;
    switch (this.suggest) {
      case "fat":
        this.imgurl="assets/img/fat.jpg";
        this.suggestvalue="你太胖了，要少吃点";
        break;
      case "normal":
        this.imgurl="assets/img/normal.jpg";
        this.suggestvalue="你的体型十分正常";
        break;
      case "overweight":
        this.imgurl="assets/img/overweight.jpg";
        this.suggestvalue="你有一点婴儿肥哦，少吃点";break;
      case "thin":
        this.imgurl="assets/img/thin.jpg";
        this.suggestvalue="你太瘦了，多吃点";break;


    }
  })
  }
}
